<%@ include file="/webapis/ui/doctype.jspf" %>

<%@ taglib uri="/bbNG" prefix="bbNG"%>
<%@ taglib uri="/bbData" prefix="bbData"%>
<%@ taglib prefix='c' uri="http://java.sun.com/jsp/jstl/core" %>  
<%@ taglib prefix='fmt' uri="http://java.sun.com/jsp/jstl/fmt" %> 

<script src="../dist/js/jquery-3.1.1.min.js" type="text/javascript"></script>

<fmt:setLocale value="${locale}"/> 
<fmt:bundle basename="messages"/>
<bbNG:genericPage>

<bbNG:jsBlock>
<script type="text/javascript">
jQuery.noConflict();
function saveCreditMap(){
	var keyList = document.getElementsByName("key");
	var valueList = document.getElementsByName("value");
	    
	var creditMapParam = "[";
	for(var i = 0; i < keyList.length; i++){
		var param = {
            "key" : keyList[i].value,
            "value" : valueList[i].value,
        };
		var obj = JSON.stringify(param);
		creditMapParam+=obj+",";
	}
	creditMapParam = creditMapParam.substring(0, creditMapParam.length-1);
	creditMapParam+="]";
	var jsonParam = JSON.parse(creditMapParam);
    jQuery.ajax({
    	async: false,
        url: "../creditresult/set",    
        contentType:"application/json",   
        dataType: "text",
        type: "POST",
        data:creditMapParam,     
        success: function (result) {  
    },
       error: function (e) {
       }
    });     
}

</script>
</bbNG:jsBlock>

<bbNG:breadcrumbBar  environment="sys_admin" navItem="admin_main">
<fmt:message key="index" var="index"/>
<bbNG:breadcrumb href="../index">index</bbNG:breadcrumb>
<bbNG:breadcrumb><fmt:message key="set.creditMap.save" var="title"/></bbNG:breadcrumb>
</bbNG:breadcrumbBar>

<bbNG:actionControlBar>
<bbNG:actionButton id="setAction" url="../creditresult/load" title="${title}" onClick = "saveCreditMap()" primary="true"/>
</bbNG:actionControlBar>
 
<form id = "listForm" action="../creditresult/loadCreditMap">
<bbNG:inventoryList collection="${creditMapSet}" objectVar="property" className="java.util.Map.Entry" url="">

<fmt:message key="set.creditMap.dbRowName" var="key"/>
<bbNG:listElement label="${key}" name="key">
	<fmt:message key="${property.getKey().toString()}"/>(${property.getKey().toString()})
	<input NAME="key" TYPE="hidden" VALUE="${property.getKey().toString()}">
</bbNG:listElement>

<fmt:message key="set.creditMap.lineitemName" var="value" />
<bbNG:listElement label="${value}" name="value" isRowHeader="true">
    <input NAME="value" VALUE="${property.getValue().toString()}">
</bbNG:listElement>

</bbNG:inventoryList>
</form>

<fmt:message key="strButOk" var="strButOk"/>
<bbNG:button id = "refreshBtn" type="PageLevel" label="${strButOk}" url="../index"/>



</bbNG:genericPage>


